#pragma once

#include "glew.h"
#include "Angel.h"

typedef Angel::vec4 color4;
typedef Angel::vec4 point4;
typedef Angel::vec3 color3;
typedef Angel::vec3 point3;
typedef Angel::vec2 point2;

enum SHADING
{
	FLAT=0,
	GOURAND,
	PHONG
};

enum COMPLEXITY
{
	MED_LOW=0,
	MED_HIGH,
	HIGH
};

class CSphere
{
public:
	CSphere::CSphere( vec3 location, float size, float rotationSpeed, SHADING shading, COMPLEXITY complexity);
	CSphere::CSphere(CSphere* hostPlanet, float distFromHost, float size, float rotationSpeed, SHADING shading, COMPLEXITY complexity);
	~CSphere(void);

	GLsizei GetNumVertices() { return m_numVertices; }
	GLsizeiptr GetPositionDataSize() { return m_pointsSize; }
	GLvoid* GetPositionData() { return m_points; }
	GLsizeiptr GetNormalDataSize() { return m_normalsSize; }
	GLvoid* GetNormalData() { return m_normals; }

	vec3 GetInitLoc() { return m_initloc; }

	mat4 GetTranslationMatrix();
	mat4 GetRotationMatrix();

	GLint GetShadingType() { return m_shading; }

private:
	static point4 m_tetrahedron_points[4];

	point3 m_initloc;
	GLfloat m_size;

	GLsizei m_numVertices;
	point4* m_points;
	point3* m_normals;

	float m_speed;
	float m_rotated;
	float m_distanceFromHost;

	SHADING m_shading;

	CSphere* m_host;

	// used for adding points
	int m_index;

	GLsizeiptr m_pointsSize;
	GLsizeiptr m_normalsSize;

	void triangle( const point4& a, const point4& b, const point4& c );
	point4 unit( const point4& p );
	void divide_triangle( const point4& a, const point4& b, const point4& c, int count );
	void tetrahedron( int count );

	void initSphere(COMPLEXITY complexity);
};

